import time


def sum_of_N(n):
    start = time.time()

    the_sum = 0
    for i in range(1, n+1):
        the_sum += i

    end = time.time()

    return the_sum, end-start


def sum_of_N_2(n):
    return n*(n+1)/2


def sum_of_3(n):
    start = time.time()

    the_sum = sum_of_N_2(n)

    end = time.time()

    return the_sum, end-start


if __name__ == '__main__':
    for i in range(10):
        the_sum, run_time = sum_of_3(100000000)
        print(f'总和是{the_sum}, 运行时间是{run_time:10.9f}')